<template>
	<div class="template-management">
		<zk-searcher v-model="query" :options="searchColumns" />
		<w-block class="body" title="督办信息列表" style="margin-top: 10px">
			<zk-table
				:columns="tableColumns"
				:service="service"
				:query="query"
				use-selection
				:actions="actions"
				:requestInterceptor="requestInterceptor"
				@onSelectionChange="onSelection"
			>
				<template #control="scope">
					<el-button size="small" type="text" @click="handleDialogRemind(scope.row.id)">再次提醒</el-button>
				</template>
			</zk-table>
		</w-block>

	</div>
</template>
<script>
import { taskSupervisionCommand as service } from '@/services'
import SearchTableCRUDMixin                  from '@/mixins/search-table-crud-mixin'

import { TYPE_ENUM } from '@/common/zk-constants'

const columns = [
	{ 'label': '项目名称', 'key': 'project_name', table: true, search: true, required: true },
	{ 'label': '工作名称', 'key': 'work_name', table: true, search: true, required: true },
	{ 'label': '任务名称', 'key': 'task_name', table: true, search: true, required: true },
	{ 'label': '责任部门', 'key': 'duty_dept', type: TYPE_ENUM.SELECT, storeKey: 'orgList', table: true, search: true, required: true },
	{ 'label': '责任人', 'key': 'done_person_name', table: true, required: true },
	{ 'label': '应完成日期', 'key': 'should_done_time', table: true, required: true },
	{ 'label': '上级督办内容', 'key': 'ld_content', table: true, required: true },
	{ 'label': '上级督办时间', 'key': 'db_time', table: true, required: true },
	{ 'label': '下发时间', 'key': 'xf_time', type: TYPE_ENUM.DATE_RANGE, rangeKeys: ['xf_time_start', 'xf_time_end'], table: true, search: true, required: true, span: 12, },
	{ 'label': '提醒次数', 'key': 'tip_num', table: true, required: true },
	{ 'label': '状态', 'key': 'db_state', type: TYPE_ENUM.SELECT, storeKey: 'partSuperviseState', table: true, search: true, required: true },
]

export default {
	mixins : [SearchTableCRUDMixin],
	data() {
		return {
			columns,
			service,
			actions            : ['slot', 180],
			//
			rowId              : undefined,
			defaultProps       : {
				children: 'children',
				label   : 'label'
			},
			defaultExpandedKeys: [],
			treeData           : [],
			checkedUser        : {
				label: '暂未指定问责人'
			},
		}
	},
	watch  : {},
	methods: {
		requestInterceptor(query) {
			return { ...query, 'pageType': 'dbxj'/*上级督办*/ }
		},
		async handleDialogRemind(id) {
			if (!id) {
				this.$message.warning(`未获取这条记录的id`)
				return;
			}
			const result = await service.doTip({ id })

			if (result) {
				this.$message.success(`提醒成功`)
				this.reload();
			}
			else {
				this.$message.warning(`提醒失败`)
			}
		},
	},
	async mounted() {
		this.treeData = await service.querySpPersonTree();
	}
}
</script>
<style scoped lang="scss">
	.command-dialog {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
	}

	.table-look-details {
		padding: 20px 0;
		width: 100%;
		border-collapse: collapse;

		td {
			border: 1px solid rgba(77, 116, 251, 0.3);
			padding: 10px 20px;
		}

		.bg-title {
			width: 200px;
			background-color: #f5f5f5;
		}

	}
</style>
